package com.zhr.liquwang.view.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import com.zhr.liquwang.R;
import com.zhr.liquwang.utils.FragmentTabUtils;
import com.zhr.liquwang.view.frg.CarFragment;
import com.zhr.liquwang.view.frg.HomeFragment;
import com.zhr.liquwang.view.frg.MyFragment;
import com.zhr.liquwang.view.frg.NearbyFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.main_frameLayout)
    LinearLayout mainFrameLayout;
    @BindView(R.id.main_rg)
    RadioGroup mainRg;
    @BindView(R.id.activity_main)
    RelativeLayout activityMain;
    private List<Fragment> frgs;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        ButterKnife.bind(this);
        frgs = new ArrayList<>();
        HomeFragment homeFragment = HomeFragment.newInstance();
        NearbyFragment nearbyFragment = NearbyFragment.newInstance();
        CarFragment carFragment = CarFragment.newInstance();
        MyFragment myFragment = MyFragment.newInstance();
        frgs.add(homeFragment);
        frgs.add(nearbyFragment);
        frgs.add(carFragment);
        frgs.add(myFragment);
        FragmentTabUtils utils = new FragmentTabUtils(getSupportFragmentManager(), frgs, R.id.main_frameLayout, mainRg, new FragmentTabUtils.OnRgsExtraCheckedChangedListener() {
            @Override
            public void OnRgsExtraCheckedChanged(RadioGroup radioGroup, int checkedId, int index) {

            }
        });
    }
}
